package com.engine.cn.base.strings;

import java.util.Objects;

public class StringTest {
    //字符串的切割函数
    public static String[] split(String resource) {
        if (Objects.isNull(resource)) {
            return new String[0];
        }

        return resource.split(",");
    }

    public static int counts(char target, String resource) {
        int count = 0;
        if (Objects.isNull(resource)) {
            return count;
        }

        int index = 0;
        while (index < resource.length()) {
            char temp = resource.charAt(index);
            if (temp == target) {
                count++;
            }
            index++;
        }

        return count;
    }

    public static int indexOf(String str) {
        int n = str.indexOf("#");
        return str.indexOf("#", n + 1);
    }

    public static void main(String[] args) {
        int count = indexOf("hello#123#456#world");
        System.out.println(count);
    }
}
